package cn.yunhe.entity;

import javax.persistence.*;
import java.io.Serializable;

@Entity(name = "书籍订单")
@Table(name = "orderbook1")
public class OrderBook implements Serializable {
    private int id;
    private int quantity;
    private double unitprice;
    private Order order;
    private Book book;

    public OrderBook() {
    }

    public OrderBook(int quantity, double unitprice, Order order, Book book) {
        this.quantity = quantity;
        this.unitprice = unitprice;
        this.order = order;
        this.book = book;
    }

    public OrderBook(int id, int quantity, double unitprice, Order order, Book book) {
        this.id = id;
        this.quantity = quantity;
        this.unitprice = unitprice;
        this.order = order;
        this.book = book;
    }

    @Id
    @GeneratedValue
    @Column(name = "id")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name = "quantity")
    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    @Column(name = "unitprice")
    public double getUnitprice() {
        return unitprice;
    }

    public void setUnitprice(double unitprice) {
        this.unitprice = unitprice;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ooid")
    public Order getOrder() {
        return order;
    }

    public void setOrder(Order order) {
        this.order = order;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "obid")
    public Book getBook() {
        return book;
    }

    public void setBook(Book book) {
        this.book = book;
    }
}
